import { useTokenStore } from "@/stores/token"
import { default as axios } from "axios"

// 封装axios
const baseURL = "http://192.168.88.157:8080/"

const request = axios.create({ baseURL })

// 请求拦截器
request.interceptors.request.use(
    (config) => {
        const useToken = useTokenStore()
        if (useToken.token) {
            config.headers.Authorization ="Bearer "+useToken.token
        }
        return config
    },
    (err) => {
        Promise.reject(err)
    }
)


export default request